﻿@using CodeBuilderForVisualStudio.Entity
@inherits RazorEngine.Templating.TemplateBase<DALFileModel>
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using @(Model.Namespace).Entity.DataTable;
using @(Model.Namespace).Entity.Base;
using @(Model.Namespace).Entity.Input.@(Model.Name);
using @(Model.Namespace).Entity.Output.@(Model.Name);
using @(Model.Namespace).IDAL;
using @(Model.Namespace).DAL.Base;


namespace @(Model.Namespace).WebApi.Controllers
{
    /// <summary>
    /// @(Model.CnName)相关api
    ///</summary>
    public class @(Model.Name)Controller : Base.BaseApiController
    {

        /// <summary>
        /// 属性注入数据访问层
        /// </summary>
        public I@(Model.Name)DAL @(Model.Name)DAL { get; set; }

        /// <summary>
        /// 获取@(Model.CnName)分页列表
        ///</summary>
        [HttpPost]
        public async Task<PageResult<Get@(Model.Name)PageOutput>> Get@(Model.Name)PageResultAsync(Get@(Model.Name)PageInput input)
        {
            return await @(Model.Name)DAL.Get@(Model.Name)PageResultAsync(input);
        }

        /// <summary>
        /// 获取@(Model.CnName)分页列表
        ///</summary>
        [HttpPost]
        public async Task<List<Get@(Model.Name)PageOutput>> Get@(Model.Name)PageListAsync(Get@(Model.Name)PageInput input)
        {
            return await @(Model.Name)DAL.Get@(Model.Name)PageListAsync(input);
        }

        /// <summary>
        /// 获取@(Model.CnName)
        /// </summary>
        [HttpPost]
        public async Task<Get@(Model.Name)Output> Get@(Model.Name)OutputAsync(BaseGuidEntity input)
        {
            return await @(Model.Name)DAL.Get@(Model.Name)OutputAsync(input);
        }

        /// <summary>
        /// 获取全部@(Model.CnName)
        /// </summary>
        [HttpGet]
        public async Task<List<Get@(Model.Name)Output>> GetAll@(Model.Name)ListAsync()
        {
            return await @(Model.Name)DAL.GetAll@(Model.Name)ListAsync();
        }

        /// <summary>
        /// 修改@(Model.CnName)
        /// </summary>
        [HttpPost]
        public async Task Update@(Model.Name)Async(Update@(Model.Name)Input input)
        {
            await @(Model.Name)DAL.Update@(Model.Name)Async(input);
        }

        /// <summary>
        /// 新增@(Model.CnName)
        /// </summary>
        [HttpPost]
        public async Task Add@(Model.Name)Async(Add@(Model.Name)Input input)
        {
            await @(Model.Name)DAL.Add@(Model.Name)Async(input);
        }

        /// <summary>
        /// 删除@(Model.CnName)
        /// </summary>
        [HttpPost]
        public async Task Delete@(Model.Name)Async(BaseIdListInput input)
        {
            await @(Model.Name)DAL.Delete@(Model.Name)Async(input);
        }
    }
}